#include "Keyboard.h"

namespace input {

	Keyboard::Keyboard( const Keyboard& keyboard ) {
		m_keys = new ButtonState[4];
		m_keys[ int( KeyboardModifier::Control ) ] = keyboard.m_keys[ int( KeyboardModifier::Control ) ];
		m_keys[ int( KeyboardModifier::Shift ) ] = keyboard.m_keys[ int( KeyboardModifier::Shift ) ];
		m_keys[ int( KeyboardModifier::Alt ) ] = keyboard.m_keys[ int( KeyboardModifier::Alt ) ];
		m_keys[ int( KeyboardModifier::Meta ) ] = keyboard.m_keys[ int( KeyboardModifier::Meta ) ];
	}

	Keyboard::Keyboard() {
		m_keys = new ButtonState[4];
		m_keys[ int( KeyboardModifier::Control ) ] = ButtonState::Released;
		m_keys[ int( KeyboardModifier::Shift ) ] = ButtonState::Released;
		m_keys[ int( KeyboardModifier::Alt ) ] = ButtonState::Released;
		m_keys[ int( KeyboardModifier::Meta ) ] = ButtonState::Released;
	}

	Keyboard::~Keyboard() {
		delete[] m_keys;
	}


	Keyboard& Keyboard::operator=( const Keyboard& other ) {
		if( this == &other ) return *this;

		m_keys[ int( KeyboardModifier::Control ) ] = other.m_keys[ int( KeyboardModifier::Control ) ];
		m_keys[ int( KeyboardModifier::Shift ) ] = other.m_keys[ int( KeyboardModifier::Shift ) ];
		m_keys[ int( KeyboardModifier::Alt ) ] = other.m_keys[ int( KeyboardModifier::Alt ) ];
		m_keys[ int( KeyboardModifier::Meta ) ] = other.m_keys[ int( KeyboardModifier::Meta ) ];

		return *this;
	}
}
